GtkAllocation *allocation);
static void gtk_label_state_changed (GtkWidget *widget,
GtkStateType state);
-static void gtk_label_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void gtk_label_style_updated (GtkWidget *widget);
static void gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static gint gtk_label_draw (GtkWidget *widget,
widget_class->destroy = gtk_label_destroy;
widget_class->size_allocate = gtk_label_size_allocate;
widget_class->state_changed = gtk_label_state_changed;
- widget_class->style_set = gtk_label_style_set;
+ widget_class->style_updated = gtk_label_style_updated;
widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->direction_changed = gtk_label_direction_changed;
widget_class->draw = gtk_label_draw;
}
static void
-gtk_label_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+gtk_label_style_updated (GtkWidget *widget)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
GtkLabelSelectionInfo *info = priv->select_info;
GtkAllocation allocation;
- GtkStyle *style;
+ GtkStyleContext *context;
+ GtkStateFlags state;
GdkWindow *window;
gint x, y;
if (priv->text && (*priv->text != '\0'))
{
+ GdkRGBA *bg_color, *fg_color;
+
get_layout_location (label, &x, &y);
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
window = gtk_widget_get_window (widget);
gtk_widget_get_allocation (widget, &allocation);
cairo_translate (cr, -allocation.x, -allocation.y);
- gtk_paint_layout (style,
- cr,
- gtk_widget_get_state (widget),
- FALSE,
- widget,
- "label",
- x, y,
- priv->layout);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_layout (context, cr,
+ x, y,
+ priv->layout);
if (info &&
(info->selection_anchor != info->selection_end))
gdk_cairo_region (cr, clip);
cairo_clip (cr);
- state = GTK_STATE_SELECTED;
- if (!gtk_widget_has_focus (widget))
- state = GTK_STATE_ACTIVE;
+ state = GTK_STATE_FLAG_SELECTED;
+
+ if (gtk_widget_has_focus (widget))
+ state |= GTK_STATE_FLAG_FOCUSED;
- gdk_cairo_set_source_color (cr, &style->base[state]);
+ gtk_style_context_get (context, state,
+ "background-color", &bg_color,
+ "color", &fg_color,
+ NULL);
+
+ gdk_cairo_set_source_rgba (cr, bg_color);
cairo_paint (cr);
- gdk_cairo_set_source_color (cr, &style->text[state]);
+ gdk_cairo_set_source_rgba (cr, fg_color);
cairo_move_to (cr, x, y);
_gtk_pango_fill_layout (cr, priv->layout);
cairo_restore (cr);
cairo_region_destroy (clip);
+
+ gdk_rgba_free (bg_color);
+ gdk_rgba_free (fg_color);
}
else if (info)
{
cairo_region_t *clip;
GdkRectangle rect;
GdkColor *text_color;
- GdkColor *base_color;
GdkColor *link_color;
GdkColor *visited_link_color;
if (active_link)
{
+ GdkRGBA *bg_color;
+
range[0] = active_link->start;
range[1] = active_link->end;
text_color = visited_link_color;
else
text_color = link_color;
+
if (info->link_clicked)
- base_color = &style->base[GTK_STATE_ACTIVE];
+ state = GTK_STATE_FLAG_ACTIVE;
else
- base_color = &style->base[GTK_STATE_PRELIGHT];
+ state = GTK_STATE_FLAG_PRELIGHT;
- gdk_cairo_set_source_color (cr, base_color);
+ gtk_style_context_get (context, state,
+ "background-color", &bg_color,
+ NULL);
+
+ gdk_cairo_set_source_rgba (cr, bg_color);
cairo_paint (cr);
gdk_cairo_set_source_color (cr, text_color);
gdk_color_free (link_color);
gdk_color_free (visited_link_color);
+ gdk_rgba_free (bg_color);
cairo_restore (cr);
}
1);
cairo_region_get_extents (clip, &rect);
- gtk_paint_focus (style, cr, gtk_widget_get_state (widget),
- widget, "label",
- rect.x, rect.y, rect.width, rect.height);
+ state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_focus (context, cr,
+ rect.x, rect.y,
+ rect.width, rect.height);
cairo_region_destroy (clip);
}